{"mode":"Text","textContent":"#region VEXcode Generated Robot Configuration\n#region VEXcode Generated Robot Configuration\nfrom vex import *\nimport urandom\n\n# Brain should be defined by default\nbrain=Brain()\n\n# Robot configuration code\nbrain_inertial = Inertial()\nIntakeGroup_motor_a = Motor(Ports.PORT5, False)\nIntakeGroup_motor_b = Motor(Ports.PORT11, True)\nIntakeGroup = MotorGroup(IntakeGroup_motor_a, IntakeGroup_motor_b)\nArmGroup_motor_a = Motor(Ports.PORT6, True)\nArmGroup_motor_b = Motor(Ports.PORT12, False)\nArmGroup = MotorGroup(ArmGroup_motor_a, ArmGroup_motor_b)\nTopTouchLED = Touchled(Ports.PORT10)\nIntakeBumper = Bumper(Ports.PORT3)\nIntakeOptical = Optical(Ports.PORT4)\nFrontDistance = Distance(Ports.PORT9)\ncontroller = Controller()\nleft_drive_smart = Motor(Ports.PORT1, 1, False)\nright_drive_smart = Motor(Ports.PORT7, 1, True)\n\ndrivetrain = SmartDrive(left_drive_smart, right_drive_smart, brain_inertial, 200)\n\n\ndef calibrate_drivetrain():\n    # Calibrate the Drivetrain Inertial\n    sleep(200, MSEC)\n    brain.screen.print(\"Calibrating\")\n    brain.screen.next_row()\n    brain.screen.print(\"Inertial\")\n    brain_inertial.calibrate()\n    while brain_inertial.is_calibrating():\n        sleep(25, MSEC)\n    brain.screen.clear_screen()\n    brain.screen.set_cursor(1, 1)\n\n\n\n# define variables used for controlling motors based on controller inputs\ncontroller_left_shoulder_control_motors_stopped = True\ncontroller_right_shoulder_control_motors_stopped = True\ndrivetrain_l_needs_to_be_stopped_controller = False\ndrivetrain_r_needs_to_be_stopped_controller = False\n\n# define a task that will handle monitoring inputs from controller\ndef rc_auto_loop_function_controller():\n    global drivetrain_l_needs_to_be_stopped_controller, drivetrain_r_needs_to_be_stopped_controller, controller_left_shoulder_control_motors_stopped, controller_right_shoulder_control_motors_stopped, remote_control_code_enabled\n    # process the controller input every 20 milliseconds\n    # update the motors based on the input values\n    while True:\n        if remote_control_code_enabled:\n            \n            # calculate the drivetrain motor velocities from the controller joystick axies\n            # left = axisA\n            # right = axisD\n            drivetrain_left_side_speed = controller.axisA.position()\n            drivetrain_right_side_speed = controller.axisD.position()\n            \n            # check if the value is inside of the deadband range\n            if drivetrain_left_side_speed < 5 and drivetrain_left_side_speed > -5:\n                # check if the left motor has already been stopped\n                if drivetrain_l_needs_to_be_stopped_controller:\n                    # stop the left drive motor\n                    left_drive_smart.stop()\n                    # tell the code that the left motor has been stopped\n                    drivetrain_l_needs_to_be_stopped_controller = False\n            else:\n                # reset the toggle so that the deadband code knows to stop the left motor next\n                # time the input is in the deadband range\n                drivetrain_l_needs_to_be_stopped_controller = True\n            # check if the value is inside of the deadband range\n            if drivetrain_right_side_speed < 5 and drivetrain_right_side_speed > -5:\n                # check if the right motor has already been stopped\n                if drivetrain_r_needs_to_be_stopped_controller:\n                    # stop the right drive motor\n                    right_drive_smart.stop()\n                    # tell the code that the right motor has been stopped\n                    drivetrain_r_needs_to_be_stopped_controller = False\n            else:\n                # reset the toggle so that the deadband code knows to stop the right motor next\n                # time the input is in the deadband range\n                drivetrain_r_needs_to_be_stopped_controller = True\n            \n            # only tell the left drive motor to spin if the values are not in the deadband range\n            if drivetrain_l_needs_to_be_stopped_controller:\n                left_drive_smart.set_velocity(drivetrain_left_side_speed, PERCENT)\n                left_drive_smart.spin(FORWARD)\n            # only tell the right drive motor to spin if the values are not in the deadband range\n            if drivetrain_r_needs_to_be_stopped_controller:\n                right_drive_smart.set_velocity(drivetrain_right_side_speed, PERCENT)\n                right_drive_smart.spin(FORWARD)\n            # check the buttonLUp/buttonLDown status\n            # to control IntakeGroup\n            if controller.buttonLUp.pressing():\n                IntakeGroup.spin(FORWARD)\n                controller_left_shoulder_control_motors_stopped = False\n            elif controller.buttonLDown.pressing():\n                IntakeGroup.spin(REVERSE)\n                controller_left_shoulder_control_motors_stopped = False\n            elif not controller_left_shoulder_control_motors_stopped:\n                IntakeGroup.stop()\n                # set the toggle so that we don't constantly tell the motor to stop when\n                # the buttons are released\n                controller_left_shoulder_control_motors_stopped = True\n            # check the buttonRUp/buttonRDown status\n            # to control ArmGroup\n            if controller.buttonRUp.pressing():\n                ArmGroup.spin(FORWARD)\n                controller_right_shoulder_control_motors_stopped = False\n            elif controller.buttonRDown.pressing():\n                ArmGroup.spin(REVERSE)\n                controller_right_shoulder_control_motors_stopped = False\n            elif not controller_right_shoulder_control_motors_stopped:\n                ArmGroup.stop()\n                # set the toggle so that we don't constantly tell the motor to stop when\n                # the buttons are released\n                controller_right_shoulder_control_motors_stopped = True\n        # wait before repeating the process\n        wait(20, MSEC)\n\n# define variable for remote controller enable/disable\nremote_control_code_enabled = True\n\nrc_auto_loop_thread_controller = Thread(rc_auto_loop_function_controller)\n#endregion VEXcode Generated Robot Configuration\n\n\n# Drivetrain, Intake, and Arm Controls defined in Devices screen\n\n# Calibrate the Drivetrain Gyro\ncalibrate_drivetrain()\nIntakeGroup.set_stopping(HOLD)\nArmGroup.set_stopping(HOLD)","textLanguage":"python","rconfig":[{"port":[5,11],"name":"IntakeGroup","customName":true,"deviceType":"MotorGroup","deviceClass":"motor_group","setting":{"fwd":"forward","rev":"reverse","motor_a_reversed":"false","motor_b_reversed":"true"},"triportSourcePort":22},{"port":[6,12],"name":"ArmGroup","customName":true,"deviceType":"MotorGroup","deviceClass":"motor_group","setting":{"fwd":"forward","rev":"reverse","motor_a_reversed":"true","motor_b_reversed":"false"},"triportSourcePort":22},{"port":[10],"name":"TopTouchLED","customName":true,"deviceType":"TouchLED","deviceClass":"touchled","setting":{},"triportSourcePort":22},{"port":[3],"name":"IntakeBumper","customName":true,"deviceType":"Bumper","deviceClass":"bumper","setting":{},"triportSourcePort":22},{"port":[4],"name":"IntakeOptical","customName":true,"deviceType":"Optical","deviceClass":"optical","setting":{},"triportSourcePort":22},{"port":[9],"name":"FrontDistance","customName":true,"deviceType":"Distance","deviceClass":"distance","setting":{},"triportSourcePort":22},{"port":[],"name":"controller","customName":false,"deviceType":"Controller","deviceClass":"controller","setting":{"left":"IntakeGroup","leftDir":"false","right":"ArmGroup","rightDir":"false","e":"","eDir":"false","f":"","fDir":"false","l3r3":"","l3r3Dir":"false","drive":"tank"},"triportSourcePort":22},{"port":[1,7,0],"name":"drivetrain","customName":false,"deviceType":"Drivetrain","deviceClass":"smartdrive","setting":{"type":"2-motor","wheelSize":"200mm","gearRatio":"1:1","direction":"fwd","gyroType":"integrated","width":"173","unit":"mm","wheelbase":"76","wheelbaseUnit":"mm","xOffset":"0","yOffset":"0","thetaOffset":"0"},"triportSourcePort":22}],"slot":0,"platform":"IQ","sdkVersion":"20220726.10.00.00","appVersion":"2.4.5","minVersion":"2.4.0","fileFormat":"1.2.0","icon":"","targetBrainGen":"Second","target":"Physical"}